package nl.unimaas.micc.eventSnookerTest.math;

public class ComplexNumber {

	private double real;
	private double imaginary;
	
	/**
	 * Creates a new complex number out of the real and imaginary part
	 * @param real 
	 * 				the real part of the complex number
	 * @param imaginary 
	 * 				the imaginary part of the complex number
	 */
	public ComplexNumber(double real, double imaginary){
		this.real = real;
		this.imaginary = imaginary;
	}
	public void setReal(double real) {
		this.real = real;
	}
	public double getReal() {
		return real;
	}
	public void setImaginary(double imaginary) {
		this.imaginary = imaginary;
	}
	public double getImaginary() {
		if(Math.abs(imaginary) > 0.001)
			return imaginary;
		return 0;
	}
	
	/**
	 * Checks if the number has a real part only
	 * @return 
	 * 			true if the number has only a real part
	 * 			false otherwise
	 */
	public boolean isRealOnly(){
		if(Math.abs(imaginary) < 0.00000001)
			return true;
		return false;
	}
	public String toString(){
		return ("[" + this.getReal() + "; " + this.getImaginary() + "]");
	}
}
